<?php

namespace App\Transformers\Admin;

use App\Models\User;
use League\Fractal\TransformerAbstract;

class DetailTransformer extends TransformerAbstract
{
    public function transform($examination)
    {
        $peoples = User::query()->whereIn('id', explode(',', $examination->peoples))->get(['id','username']);
        $reviewer = User::query()->whereIn('id',explode(',', $examination->reviewer))->get(['id','username']);
        return [
            'category_id' => $examination->category_id,
            'name' => $examination->name,
            'start_time' => $examination->start_time,
            'over_time' => $examination->over_time,
            'timer' => $examination->timer,
            'peoples' => $peoples,
            'status' => $examination->status,
            'subject_id' => $examination->subject,
            'show_result' => $examination->show_result,
            'show_answer' => $examination->show_answer,
            'mouse_out' => $examination->mouse_out,
            'mouse_out_num' => $examination->mouse_out_num,
            'reviewer' => $reviewer,
            'examination_mode' => $examination->examination_mode,
            'type' => $examination->type,
            'test_list_id' => $examination->test_list_id
        ];

    }
}

